using Commons.Models.Definitions;
using Commons.Models.Settings.Dtos.Stats;
using System.Collections.Generic;

namespace Commons.Models.Settings.Mappers.Stats
{
	public class UserStatsMapper : IMapper<StatsDto, List<IStatDefinition>>
	{
		public List<IStatDefinition> Map (StatsDto config)
		{
			List<IStatDefinition> stats = new List<IStatDefinition>();

			if (config.SimpleStats != null)
			{
				SimpleStatMapper mapper = new SimpleStatMapper();
				foreach (SimpleStatDto stat in config.SimpleStats)
				{
					stats.Add(mapper.Map(stat));
				}
			}

			if (config.LeveledStats != null)
			{
				LeveledStatMapper mapper = new LeveledStatMapper();
				foreach (LeveledStatDto stat in config.LeveledStats)
				{
					stats.Add(mapper.Map(stat));
				}
			}

			return stats;
		}
	}
}